package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseBaseVO;
import com.xuecheng.content.entity.CourseBase;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 转换器，把courseBase-->courseBaseDTO
 */
@Mapper
public interface CourseConvert {

    //构建属性转换示例
    CourseConvert INSTANCE = Mappers.getMapper(CourseConvert.class);

    /**
     * 转换单个的courseBase-->courseBaseDTO
     * @param courseBase  #courseBase的对象
     * @return #courseBase封装后的DTO对象
     */
    @Mapping(source = "id",target = "courseBaseId")
    CourseBaseDTO entity2DTO(CourseBase courseBase);

    /**
     * courseBase集合-->>courseBaseDTO集合
     * @param courseBaseList #courseBase的集合
     * @return  #courseBase集合封装后的DTO集合
     */
    List<CourseBaseDTO> entitys2DTOs(List<CourseBase> courseBaseList);


    /*
       把DTO--->PO
     */
    @Mapping(source = "courseBaseId",target = "id")
    CourseBase DTO2entity(CourseBaseDTO dto);

    List<CourseBase> DTOs2entitys(List<CourseBaseDTO> dtoList);

    /*
    把VO-->>DTO
     */


    CourseBaseDTO vo2DTO(CourseBaseVO vo);

    List<CourseBaseDTO> vos2DTOs(List<CourseBaseVO> voList);
}
